<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
		<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
		<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
		<title>注册用户</title>
	</head>
	
	<body style="margin-top: 100px;">
		<h2 style="text-align: center;">注册账号</h2>
		<form action = "" method = "post" style="text-align: center;" name="a" onsubmit="return check()" class="form-horizontal" role="form">
			<div class="form-group">
				<div class="col-sm-3"></div>
				<label  class="col-sm-2 control-label">用户名:</label>
				<div class="col-sm-2"><input class="form-control" type = "text" name = "username"></div>
			</div>
			<div class="form-group">
				<div class="col-sm-3"></div>
				<label  class="col-sm-2 control-label">密码:</label>
				<div class="col-sm-2"><input class="form-control" type = "text" name = "password"></div>
			</div>
			<div class="form-group">
				<div class="col-sm-3"></div>
				<label  class="col-sm-2 control-label">确认密码:</label>
				<div class="col-sm-2"><input class="form-control" type = "text" name = "re_password"></div>
			</div>
			<div class="form-group">
				<div class="col-sm-3"></div>
				<label  class="col-sm-2 control-label">输入学号:</label>
				<div class="col-sm-2"><input class="form-control" type = "text" name = "stuid"></div>
			</div>
			<div class="form-group">
				<div class="col-sm-3"></div>
				<label  class="col-sm-2 control-label">输入班级:</label>
				<div class="col-sm-2"><input class="form-control" type = "text" name = "class"></div>
			</div>
			<input type = "submit" value = "立即注册" name = "subr" class="btn btn-primary" style="width: 150px">
</form>
<div style="margin-top: 100px;text-align: center;"><img src="img/福州大学至诚学院8字.png" width="50%"/></div>
</body>
<script>
	function check() 
	{ 
	if(document.a.username.value.length<2) 
	{ 
	alert("用户名不能低于2位！"); 
	document.a.username.focus(); 
	return false; 
	}
	if(document.a.password.value.length<6)
	{ 
	alert("密码不能低于6位！"); 
	document.a.password.focus(); 
	return false; 
	}
	if((document.a.password.value)!=(document.a.re_password.value))
	{ 
	alert("两次输入的密码不同！"); 
	document.a.password.focus(); 
	return false; 
	}
	if(document.a.stuid.value.length==0)
	{ 
	alert("学号不能为空！"); 
	document.a.class.focus(); 
	return false; 
	}
	if(document.a.class.value.length==0)
	{ 
	alert("班级不能为空！"); 
	document.a.class.focus(); 
	return false; 
	}
	} 

</script>
</html>

<?php
include_once("conn.php");
if(isset($_POST["subr"])){
$clss=$_POST['username'];
$kemu=$_POST['password'];
$time=$_POST['re_password'];
$teacher=$_POST['stuid'];
$result=mysqli_query($conn,"insert into useu values('$clss','$kemu','$time','$teacher','0')");
header("Location:registersucc.php");
}

?>